import 'dart:io';

import 'package:shared_preferences/shared_preferences.dart';

var conf = Config();

class Config {
  // 屏幕显示比例
  List<int> bili = [1, 1];
  double fontsise = 28;
  double inputW = 300;
  // 默认打开地址
  String? defaultPath = "";
  String? nowFilePath = "";
}

Future<void> saveData(String key, value) async {
  SharedPreferences prefs = await SharedPreferences.getInstance();
  await prefs.setString(key, value); // 使用键值对保存数据
}

Future<String?> readData(String key) async {
  SharedPreferences prefs = await SharedPreferences.getInstance();
  String? data = prefs.getString(key); // 读取数据，如果不存在则返回默认值
  if (Platform.isWindows) {
    data = null;
    return data;
  } else {
    data ??= "~";
  }
  return data;
}
